package com.chen.dao.role;

import com.chen.dao.BaseDao;
import com.chen.pojo.Role;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class RoleDaoImp implements RoleDao{
    public List<Role> getRoleList(Connection con) throws SQLException {
        PreparedStatement ps = null;
        ResultSet rs = null;
        List<Role> roleList = new ArrayList<>();
        if (con != null){
            String sql = "select id,roleName,roleCode from smbms_role";
            Object[] params = {};
            rs = BaseDao.execute(con, ps, rs, sql, params);
            while (rs.next()){
                Role role = new Role();
                role.setId(rs.getInt("id"));
                role.setRoleCode(rs.getString("roleCode"));
                role.setRoleName(rs.getString("roleName"));
                roleList.add(role);
            }
        }
        return roleList;
    }
}
